home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-22 | 4.1 KB | 143 lines | [TEXT/CWIE] |
- // =================================================================================
- // CGreyCaption.cp ©1997 BB's Team Inc. All rights reserved
- // =================================================================================
- #include "CGreyCaption.h"
-
- #include <UDrawingState.h>
- #include <UDrawingUtils.h>
- #include <UGWorld.h>
- #include <UTextTraits.h>
-
-
- // ---------------------------------------------------------------------------------
- // • CreateGreyCaptionStream [static]
- // ---------------------------------------------------------------------------------
- CGreyCaption *
- CGreyCaption::CreateGreyCaptionStream(
- LStream *inStream )
- {
- return new CGreyCaption (inStream);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CGreyCaption
- // ---------------------------------------------------------------------------------
- CGreyCaption::CGreyCaption()
- : LCaption()
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CGreyCaption(SPaneInfo&)
- // ---------------------------------------------------------------------------------
- CGreyCaption::CGreyCaption(
- const SPaneInfo &inPaneInfo,
- ConstStringPtr inString,
- ResIDT inTextTraitsID)
- : LCaption (inPaneInfo, inString, inTextTraitsID)
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CGreyCaption(const CGreyCaption&)
- // ---------------------------------------------------------------------------------
- CGreyCaption::CGreyCaption(
- const CGreyCaption &inOriginal )
- : LCaption ( inOriginal )
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CGreyCaption(LStream*)
- // ---------------------------------------------------------------------------------
- CGreyCaption::CGreyCaption(
- LStream *inStream )
- : LCaption (inStream)
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ~CGreyCaption
- // ---------------------------------------------------------------------------------
- CGreyCaption::~CGreyCaption()
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • Refresh
- // ---------------------------------------------------------------------------------
- void CGreyCaption::Refresh()
- {
- Draw (nil);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • DrawSelf
- // ---------------------------------------------------------------------------------
- void
- CGreyCaption::DrawSelf()
- {
- const RGBColor Col1 = { 222*256, 222*256, 222*256 };
- const RGBColor Col2 = { 189*256, 189*256, 189*256 };
- const RGBColor Col3 = { 140*256, 140*256, 140*256 };
- const RGBColor Col4 = { 82*256, 82*256, 82*256 };
- const RGBColor ColB = { 0*256, 0*256, 0*256 };
- const RGBColor ColW = { 255*256, 255*256, 255*256 };
-
- // Calculate the frame rect.
- Rect theFrame;
- CalcLocalFrameRect (theFrame);
-
-
- // enough to make it draw offscreen !
- StOffscreenGWorld offWorld (theFrame, 8);
- StColorState::Normalize();
-
-
- // Fill with Grey
- ::RGBBackColor (&Col1);
- ::EraseRect (&theFrame);
-
- // Draw Text asap to avoid flickering
- Int16 just = UTextTraits::SetPortTextTraits(mTxtrID);
-
- RGBColor textColor;
- ::GetForeColor(&textColor);
-
- ApplyForeAndBackColors();
- ::RGBForeColor(&textColor);
-
- Rect textRect = theFrame; // Modify the frame not to write against the border
- ::InsetRect (&textRect, 2, 2);
- ::OffsetRect (&textRect, 3, 1);
-
- UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0], textRect, just);
-
- // Light (white)
- ::RGBForeColor (&ColW);
- ::MoveTo (theFrame.left, theFrame.top); // above
- ::Line (theFrame.right-theFrame.left-2, 0);
- ::MoveTo (theFrame.left, theFrame.top); // and left
- ::Line (0, theFrame.bottom-theFrame.top-2);
-
- // Shadow
- ::RGBForeColor (&Col3);
- ::MoveTo (theFrame.left+1, theFrame.bottom-1); // below
- ::Line (theFrame.right-theFrame.left, 0);
- ::MoveTo (theFrame.right-1, theFrame.top+1); // and right
- ::Line (0, theFrame.bottom-theFrame.top-2);
-
- // Black separator underneath
- ::RGBForeColor (&ColB);
- ::MoveTo (theFrame.left, theFrame.bottom);
- ::Line (theFrame.right-theFrame.left, 0);
-
- }
-